package pro.cherish.knowledgecmomon.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 创建人：cherish
 * @version 版本号：V1.0
 * <p>
 * ***************************修订记录************************************
 * 2019-11-02 cherish 创建该类功能。
 * **********************************************************************
 * </p>
 * @ClassName 类名：TreeBean
 * @Description 功能说明：
 * <p>
 * TODO
 * </p>
 * **********************************************************************
 * @date 创建日期： 2019-11-02 cherish
 */

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@ApiModel("树形结构")
public class TreeBean implements Comparable<TreeBean> , Serializable {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty("唯一标识")
    private String id;
    @ApiModelProperty("编码")
    private String code;
    @ApiModelProperty("显示内容")
    private String text;
    @ApiModelProperty("父ID")
    private String pid;
    @ApiModelProperty("属性对象")
    private Object attributes;
    @ApiModelProperty("是否选中")
    private boolean checked = false;
    @ApiModelProperty("展开")
    private boolean opened = false;
    @ApiModelProperty("是否叶子节点")
    private boolean leaf;
    @ApiModelProperty("级数【从1开始】")
    private Integer rank;
    @ApiModelProperty("子节点")
    private List<TreeBean> children = new ArrayList<TreeBean>();

    @Override
    public int compareTo(TreeBean treeBean) {
        return this.getCode().compareTo(treeBean.getCode());
    }
}

